//    Copyright (C) Kherty.  All rights reserved.
using System.Globalization;
using OpenLS.Core.Serialization;

namespace OpenLS.Chart
{
    internal class AnchorMarker : IOfficeXmlSerializableAs
    {
        private double _x;

        private double _y;

        public double X
        {
            get { return _x; }
            set { _x = value; }
        }

        public double Y
        {
            get { return _y; }
            set { _y = value; }
        }

        #region IOfficeXmlSerializableAs Members

        void IOfficeXmlSerializableAs.ReadXmlAs(string name, ReadContext context)
        {
            using (var c = context.Read(name))
            {
                using (ReadContext c2 = c.Read("x"))
                {
                    X = double.Parse(c2.ReadString(), CultureInfo.InvariantCulture);
                }
                using (ReadContext c2 = c.Read("y"))
                {
                    Y = double.Parse(c2.ReadString(), CultureInfo.InvariantCulture);
                }
            }
        }

        void IOfficeXmlSerializableAs.WriteXmlAs(string name, WriteContext context)
        {
            using (WriteContext c = context.Write(name))
            {
                using (WriteContext c2 = c.Write("x"))
                {
                    c2.WriteString(X.ToString());
                }
                using (WriteContext c2 = c.Write("y"))
                {
                    c2.WriteString(Y.ToString());
                }
            }
        }

        #endregion
    }
}